﻿using System;
using System.Collections.Generic;
using Castle.ActiveRecord;
using CosyTrade.Data;
using CosyTrade.Financial;
using CosyTrade.Organization;

namespace CosyTrade.Futures
{
    /// <summary>
    /// 出口单
    /// </summary>
    [ActiveRecord("tbExportOrder"), Serializable]
    public class ExportOrder : BusinessObject 
    {
        private readonly Guid primaryKey = Guid.NewGuid();
        [PrimaryKey(PrimaryKeyType.Assigned, "ROWGUID", Access = PropertyAccess.NosetterCamelcase)]
        public override Guid PrimaryKey
        {
            get { return primaryKey; }
        }

        /// <summary>
        /// 出口单编号
        /// </summary>
        private string exportId;
        /// <summary>
        /// 入口单号
        /// </summary>
        private string importId;
        /// <summary>
        /// 订单内容
        /// </summary>
        //private IList<ExportWares> orderWares = new List<ExportWares>();
        /// <summary>
        /// 客户联系方式
        /// </summary>
        private string clientContent;
        /// <summary>
        /// 下单人
        /// </summary>
        private Employee makeOrder;
        /// <summary>
        /// 下单日期
        /// </summary>
        private DateTime makeOrderDate = DateTime.Now;
        /// <summary>
        /// 预计出货日期
        /// </summary>
        private DateTime shipmentDate;
        /// <summary>
        /// 发货日期
        /// </summary>
        private DateTime sendGoodsDate;
        /// <summary>
        /// 商品总数
        /// </summary>
        private int waresCount;
        /// <summary>
        /// 出口单状态
        /// </summary>
        private ExpImpOrderState orderState;
        /// <summary>
        /// 收货人
        /// </summary>
        private Employee reviceGoodser;
        /// <summary>
        /// 收货公司
        /// </summary>
        private Company reviceCompany;
        /// <summary>
        /// 出口单总价
        /// </summary>
        private double exportValues;
        /// <summary>
        /// 出口汇率
        /// </summary>
        private ExchangeRate exchange;
        /// <summary>
        /// 入口总价
        /// </summary>
        private double importTotalPrice;
        /// <summary>
        /// 入口汇率
        /// </summary>
        private ExchangeRate importExchange;
        /// <summary>
        /// 出入口总差价
        /// </summary>
        private double priceDifference;

        /// <summary>
        /// 出口单编号
        /// </summary>
        [Property]
        public string ExportId
        {
            get { return exportId; }
            set { exportId = value; }
        }

        /// <summary>
        /// 入口单号
        /// </summary>
        [Property]
        public string ImportId
        {
            get { return importId; }
            set { importId = value; }
        }

        /// <summary>
        /// 订单内容
        /// </summary>
        //[HasAndBelongsToMany(typeof(ExportWares),ColumnKey = "ExportOrderKey",ColumnRef = "ExportWareKey", Table = "ExportOrderAndWares",Access = PropertyAccess.NosetterCamelcase)]
        //public IList<ExportWares> OrderWares
        //{
        //    get { return orderWares; }
        //}

        /// <summary>
        /// 客户联系方式
        /// </summary>
        [Property]
        public string ClientContent
        {
            get { return clientContent; }
            set { clientContent = value; }
        }

        /// <summary>
        /// 下单人
        /// </summary>
        [BelongsTo]
        public Employee MakeOrder
        {
            get { return makeOrder; }
            set { makeOrder = value; }
        }

        /// <summary>
        /// 下单日期
        /// </summary>
        [Property]
        public DateTime MakeOrderDate
        {
            get { return makeOrderDate; }
            set { makeOrderDate = value; }
        }

        /// <summary>
        /// 预计出货日期
        /// </summary>
        [Property]
        public DateTime ShipmentDate
        {
            get { return shipmentDate; }
            set { shipmentDate = value; }
        }

        /// <summary>
        /// 发货日期
        /// </summary>
        [Property]
        public DateTime SendGoodsDate
        {
            get { return sendGoodsDate; }
            set { sendGoodsDate = value; }
        }

        /// <summary>
        /// 商品总数
        /// </summary>
        [Property]
        public int WaresCount
        {
            get { return waresCount; }
            set { waresCount = value; }
        }

        /// <summary>
        /// 出口单状态
        /// </summary>
        [Property]
        public ExpImpOrderState OrderState
        {
            get { return orderState; }
            set { orderState = value; }
        }

        /// <summary>
        /// 收货人
        /// </summary>
        [BelongsTo]
        public Employee ReviceGoodser
        {
            get { return reviceGoodser; }
            set { reviceGoodser = value; }
        }

        /// <summary>
        /// 收货公司
        /// </summary>
        [BelongsTo]
        public Company ReviceCompany
        {
            get { return reviceCompany; }
            set { reviceCompany = value; }
        }

        /// <summary>
        /// 出口单总价
        /// </summary>
        [Property]
        public double ExportValues
        {
            get { return exportValues; }
            set { exportValues = value; }
        }

        /// <summary>
        /// 出口汇率
        /// </summary>
        [BelongsTo]
        public ExchangeRate Exchange
        {
            get { return exchange; }
            set { exchange = value; }
        }

        /// <summary>
        /// 入口总价
        /// </summary>
        [Property]
        public double ImportTotalPrice
        {
            get { return importTotalPrice; }
            set { importTotalPrice = value; }
        }

        /// <summary>
        /// 入口汇率
        /// </summary>
        [BelongsTo]
        public ExchangeRate ImportExchange
        {
            get { return importExchange; }
            set { importExchange = value; }
        }

        /// <summary>
        /// 出入口总差价
        /// </summary>
        [Property]
        public double PriceDifference
        {
            get { return priceDifference; }
            set { priceDifference = value; }
        }
    }
}